{{!
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
}}


<div id="config_history_flow" {{bindAttr class="view.showCompareVersionBar:two-stories-bar:one-story-bar"}}>
  <div class="version-slider">
    <div {{bindAttr class=":icon-chevron-box :pull-left view.showLeftArrow::disabled"}} {{action shiftBack target="view"}} data-toggle="arrow-tooltip"
      {{bindAttr data-original-title="view.leftArrowTooltip"}}><i class="icon-chevron-left icon-3x"></i></div>
    <div {{bindAttr class=":icon-chevron-box :pull-left view.showRightArrow::disabled"}} {{action shiftForward target="view"}} data-toggle="arrow-tooltip"
      {{bindAttr data-original-title="view.rightArrowTooltip"}}><i class="icon-chevron-right icon-3x"></i></div>
    {{#each serviceVersion in view.visibleServiceVersion}}
      {{view view.serviceVersionBox serviceVersionBinding=serviceVersion}}
    {{/each}}

  </div>
  <div class="version-info-bar-wrapper">
    {{#if App.isManager}}
      <div {{bindAttr class="view.showCompareVersionBar::hidden :version-info-bar"}}>
          <div class="row-fluid">
              <div class="span1 remove-compare-bar" {{action removeCompareVersionBar target="view"}} data-toggle="arrow-tooltip" {{translateAttr data-original-title="services.service.config.configHistory.dismissIcon.tooltip"}}>
                  <i class="icon-remove-circle icon-large"></i>
              </div>
              <div class="label-wrapper span8"
                   data-toggle="tooltip" {{bindAttr data-original-title="view.compareServiceVersion.fullNotes"}}>
                  {{t services.service.config.configHistory.comparing}}
                  <span class="label label-info">{{view.displayedServiceVersion.versionText}}</span>
                  ...
                  <span class="label label-info">{{view.compareServiceVersion.versionText}}</span>
                {{#if view.compareServiceVersion.isCurrent}}
                    <span class="label label-success">{{t common.current}}</span>
                {{/if}}
                  <strong>{{view.compareServiceVersion.author}}</strong>&nbsp;{{t dashboard.configHistory.info-bar.authoredOn}}
                  &nbsp;<strong>{{view.compareServiceVersion.createdDate}}</strong>
              </div>
              <div class="pull-right operations-button">
                  <button class="btn btn-success"  {{action doAction view.serviceVersionsReferences.compare view.actionTypes.REVERT target="view"}} {{bindAttr disabled="view.versionActionsDisabled" class="view.compareServiceVersion.isCurrent:hidden"}}>{{view.compareServiceVersion.makeCurrentButtonText}}</button>
              </div>
          </div>
      </div>
    {{/if}}
      <div class="version-info-bar">
        <div class="row-fluid">
            <div class="btn-group pull-left">
              <button id="toggle-dropdown-button" class="btn dropdown-toggle" data-toggle="dropdown" href="#" {{action hideFullList target="view"}} {{bindAttr disabled="view.versionActionsDisabled"}}>
                <i class="icon-random"></i>
                <span class="caret"></span>
              </button>
              <ul class="dropdown-menu">
                {{#each serviceVersion in view.dropDownList}}
                  <li {{bindAttr class=":pointer :dropdown-submenu serviceVersion.isDisplayed:not-allowed"}}>
                    <div class="row-fluid version-in-dropdown " {{action doAction serviceVersion view.actionTypes.SWITCH target="view"}}>
                      <div class="span2">{{serviceVersion.versionText}}</div>
                      <div class="span6">{{serviceVersion.createdDate}}</div>
                      <div class="span3">{{serviceVersion.author}}</div>
                      <div class="pull-right"><i class="icon-caret-right"></i></div>
                    </div>
                    <ul class="dropdown-menu version-info-operations">
                      <div class="content">
                        <span class="label label-info">{{serviceVersion.versionText}}</span>
                        <div class="group"><strong>{{serviceVersion.configGroupName}}</strong></div>
                        <div class="date"><strong>{{serviceVersion.author}}</strong>&nbsp;{{t dashboard.configHistory.info-bar.authoredOn}}&nbsp;<strong>{{serviceVersion.createdDate}}</strong></div>
                        <div class="notes">{{{serviceVersion.fullNotes}}}</div>
                      </div>
                      <div class="version-operations-buttons">
                        <button {{bindAttr disabled="serviceVersion.disabledActionAttr.view" class=":btn serviceVersion.isDisplayed:not-allowed-cursor" title="serviceVersion.disabledActionMessages.view"}} {{action doAction serviceVersion view.actionTypes.SWITCH target="view"}}><i class="icon-search"></i>&nbsp;{{t common.view}}</button>
                        {{#if App.isManager}}
                        <button {{bindAttr disabled="serviceVersion.disabledActionAttr.compare" class=":btn serviceVersion.isDisplayed:not-allowed-cursor" title="serviceVersion.disabledActionMessages.compare"}} {{action doAction serviceVersion view.actionTypes.COMPARE target="view"}}><i class="icon-copy"></i>&nbsp;{{t common.compare}}</button>
                        <button {{bindAttr disabled="serviceVersion.disabledActionAttr.revert" class=":btn serviceVersion.isCurrent:not-allowed-cursor" title="serviceVersion.disabledActionMessages.revert"}} {{action doAction serviceVersion view.actionTypes.REVERT target="view"}}>{{t dashboard.configHistory.info-bar.revert.button}}</button>
                        {{/if}}
                      </div>
                    </ul>
                  </li>
                {{/each}}
                {{#unless view.showFullList}}
                    <li class="align-center pointer" id="show_more">
                        <a {{action openFullList target="view"}}>
                          {{t dashboard.configHistory.info-bar.showMore}}&nbsp;{{view.displayName}}
                            &nbsp;<span class="lowercase ellipsis">{{t dashboard.configHistory.title}}</span>
                        </a>
                    </li>
                {{/unless}}
              </ul>
            </div>
            <div class="label-wrapper span8" data-toggle="tooltip" {{bindAttr data-original-title="view.displayedServiceVersion.fullNotes"}}>
              {{#if view.displayedServiceVersion.versionText}}
                <span class="label label-info">{{view.displayedServiceVersion.versionText}}</span>
              {{/if}}
              {{#if view.displayedServiceVersion.isCurrent}}
                  <span class="label label-success">{{t common.current}}</span>
              {{/if}}
              {{#if view.displayedServiceVersion.author}}
                <strong>{{view.displayedServiceVersion.author}}</strong>&nbsp;{{t dashboard.configHistory.info-bar.authoredOn}}&nbsp;<strong>{{view.displayedServiceVersion.createdDate}}</strong>
              {{/if}}
            </div>
          {{#if App.isManager}}
            <div class="pull-right operations-button">
                <div {{bindAttr class="view.displayedServiceVersion.isCurrent::hidden"}}>
                    <button class="btn" {{action doCancel target="controller"}} {{bindAttr disabled="view.isDiscardDisabled"}}>{{t common.discard}}</button>
                    <button class="btn btn-success" {{action save target="view"}} {{bindAttr disabled="view.isSaveDisabled"}}>{{t common.save}}</button>
                </div>
                <button class="btn btn-success"  {{action doAction view.serviceVersionsReferences.displayed view.actionTypes.REVERT target="view"}} {{bindAttr disabled="view.versionActionsDisabled" class="view.displayedServiceVersion.isCurrent:hidden"}}>{{view.displayedServiceVersion.makeCurrentButtonText}}</button>
            </div>
          {{/if}}
        </div>
      </div>
  </div>
</div>
